/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2022-07-30
 * Time: 15:25
 */
public class StudyMethod {

    //求两个整数的和
    public static int add(int a,int b){
        return a+b;
    }
    public static double add(double c,double d){
        return c+d;
    }

    public static void main(String[] args) {
        int x = 10;
        int y = 20;
        int ret = add(x,y);
        System.out.println(ret);
        double m = 11.2;
        double n = 22.4;
        double res = add(m,n);
        System.out.println(String.format("%.2f",res));
    }






    //求n的阶乘的和
    public static int facNum(int n){
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int rs = fac(i);
            sum += rs;
        }
        return (sum);
    }
    public static  int fac(int n){
        int res = 1;
        for (int i = 1; i <= n; i++) {
            res *= i;
        }
        return res;

    }
    public static void main3(String[] args) {
        int n = 2;
        int end = facNum(n);
        System.out.println(end);
    }



    //两个数相加有返回值
    public static int add2(int a,int b){
        return(a + b);
    }
    public static void main2(String[] args) {
        int x = 5;
        int y = 1;
        int ret = add2(x , y);
        System.out.println(ret);
    }


    //两个数相加无返回值
    public static void add3(int a,int b){
        System.out.println(a + b);
    }

    public static void main1(String[] args) {
       int x = 7;
       int y = 2;
       add3(x , y);//实际参数
    }
}
